The technology described herein relates to methods of and apparatus for encoding and decoding data, and in particular to such methods and apparatus for use when compressing and decompressing texture data for use in computer graphics systems.
It is common in computer graphics systems to generate colours for sampling positions in an image to be displayed by applying so-called textures or texture data to the surfaces to be drawn. For example, surface detail on objects may be generated by applying a predefined “texture” to a set of graphics primitives (such as polygons) representing the object, to give the rendered image of the object the appearance of the “texture”. Such textures are typically applied by storing an array of texture elements or “texels”, each representing given texture data (such as colour, luminance, and/or light/shadow, etc., values) at a given location (position), and then mapping the texels onto the corresponding elements, such as (and, indeed, typically) a set of sampling positions, for the image to be displayed. The stored arrays of texture elements (data) are typically referred to as “texture maps”.
Such arrangements can provide relatively high image quality, but have a number of drawbacks. In particular, the storage of the texture data and accessing it in use can place, e.g., high storage and processing requirements on a graphics processing device (or conversely lead to a loss in performance where such requirements are not met). This is particularly significant for lower power, mobile, and handheld, devices that perform graphics processing, as such devices are inherently limited in their, e.g., storage, bandwidth and power resources and capabilities.
It is known therefore to try to encode such texture data in a “compressed” form so as to try to reduce, e.g., the storage and bandwidth burden that may be imposed on a graphics processing device when using textures.
Texture compression techniques typically determine a reduced set or palette of colours (or other data) to be used for, e.g., a given texture map, and then store for each texture element (texel) in the texture map an index into the set or palette of colours, indicating the colour to be used for the texture element (texel) in question. This has the advantage that only an index, rather than a full, e.g. colour, value needs to be stored for each texel.
It is also common for existing texture compression techniques to use block-based encoding, i.e. arrangements in which the overall array of texture elements (the texture map) to be encoded is divided into an array of small blocks (such as blocks of 4×4 texels), with each such block then being encoded (compressed), and decoded, separately. This can, e.g., help to make the decoding process more efficient, because the decoder, for example, may need to decode only one or a few of the encoded blocks to determine the value of a texel of interest, rather than the entire encoded texture.
One known block-based texture compression technique is so-called block truncation encoding (BTC). In this technique the overall texture array (texture map) is subdivided into smaller blocks, e.g. of 4×4 texels, and a number (typically two) of base or primary colour values are determined for each such block, with each texel in the block being set to one of the base colour values. This saves on the data that has to be stored and accessed, but at a cost of lower image quality.
U.S. Pat. No. 5,047,853 describes an improved block truncation coding technique. In this technique, two base colours are again stored for each texel block, but two additional colours to be used for the block are also derived from those two base colours (e.g. by linearly blending those colours). In this way, four colours are provided as a “palette” for the texel block, but only two colour values need to be stored for the block. Each texel in the block is then encoded using two bits, to indicate which of the four block “colours” should be used for the texel. This system provides improved image quality over basic block truncation coding, but requires more data per block.
Known block-based texture compression schemes all use rectangular blocks. This is because it is easy to divide a texture map into blocks this way, the blocks will tile (tessellate) straightforwardly, and it facilitates straightforward determination from a texel's coordinates of which block the texel is in and the texel it is within that block (for example, for 4×4 square blocks, dividing the texel's x and y coordinates by 4 identifies the block, and the remainder in x and y identifies the texel). Such straightforward identification of the block a texel is in, and the texel it is within the block, facilitates random access into the stored texture data (texture map). This is important in texture compression schemes, because, as is known in the art, the decoder will access the stored and compressed texture data (texture map) in a random access fashion, and so storing the compressed texture data (texture map) in a form that facilitates efficient random access into it is important and advantageous.
Although using rectangular blocks for block-based texture compression schemes has a number of benefits, it can lead to certain encoding artefacts in the decompressed (decoded) image. This is because the approximations made when encoding adjacent blocks can lead to mismatches at the block edges. Although these errors may in themselves be small, because all the block edges line up, they can result in linear features that are noticeable in the decoded image.
It is known therefore to try to reduce the effect and/or possibility of such block “edge” artefacts arising. For example, the encoding process may be tuned to reduce block edge artefacts. However, this is usually at the expense of detail in the interior of each block. Some decoding processes interpolate data from adjacent blocks to decode a given texel, thereby, in effect, “blending” adjacent blocks. This can help to reduce block edge mismatches, but is relatively expensive as it can, e.g., require reads from up to four encoded blocks to decode one texel. It is also known to apply some form of filtering to the decoded image to try to reduce the effect of block edge artefacts, but this requires post-processing of the decoded image, which is not always desirable or possible.
The Applicants believe therefore that there remains scope for improved block-based texture compression schemes that are to be used for encoding texture data for use in graphics processing.
Like numerals are used for like features in the drawings (where appropriate).